package com.sun.common.core.model.dto;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
public class DataDTO<T>  implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 数据集合
     */
    @ApiModelProperty(value = "数据集合", example = "[]", required = true, position = 0)
    private T list;

    /**
     * 分页信息
     */
    @ApiModelProperty(value = "分页信息", example = "", required = true, position = 1)
    private PageDTO pagination;

    public DataDTO(T list, IPage page){
        this.setList(list);
        this.setPagination(new PageDTO(page.getTotal(), page.getSize(), page.getCurrent()));
    }
}
